package com.lichao.FinkDataProcess.source;

import org.apache.flink.streaming.api.functions.source.SourceFunction;

public class CustomizeSource implements SourceFunction<String> {


    // 声明一个布尔变量，作为控制数据生成的标识位
    private Boolean running = true;

    @Override
    public void run(SourceContext<String> ctx) throws Exception {
        String json = "{\"moduleid\":\"123\",\"pageid\":\"123\",\"eventid\":\"ku_test\"}";
        while (running) {
            ctx.collect(json);
            // 隔 1 秒生成一个点击事件，方便观测
            Thread.sleep(1000);
        }
    }

    @Override
    public void cancel() {
        running = false;
    }

}
